/**
 * 
 */
package View;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.Label;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.WindowConstants;

import Model.contact;

/**
 * @author enzo
 *
 */
public class MainFrame extends JFrame {
	private Menu sortMenu;
	private Form formView;
	private JPanel contentPanel;
	private JLabel header;
	private ListView contactList;
	private ContactView display;

	public MainFrame(List<contact> list)
	{
		formView=new Form();
		contactList = new ListView(list);
		sortMenu=new Menu();
		display=new ContactView();
		header= new JLabel("Address Book",SwingConstants.CENTER);
		Font headerFont = new Font("Serif", Font.BOLD, 25);
		header.setFont(headerFont);
		contentPanel=new JPanel();
		contentPanel.setLayout(new BorderLayout(30,20));
		contentPanel.add("Center",formView);
		contentPanel.add("West",contactList);
		contentPanel.add("North",header);
		this.setSize(800, 600);
		this.setContentPane(contentPanel);
		this.setJMenuBar(sortMenu);
		this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
		this.setVisible(true);
		setResizable(false);
	}
	
	public void switchToContactView()
	{
		contentPanel.remove(formView);
		contentPanel.add("Center",display);
		this.setContentPane(contentPanel);
	}
	public void switchToFormView()
	{
		
		contentPanel.remove(display);
		contentPanel.add("Center",formView);
		this.setContentPane(contentPanel);
		contactList.getContactList().clearSelection();
	}
	public void switchToAlterView(contact c)
	{
	contentPanel.remove(display);
	formView.AlterForm(c);
	contentPanel.add("Center",formView);
	this.setContentPane(contentPanel);
		
	}

	/**
	 * @return the formView
	 */
	public Form getFormView() {
		return formView;
	}

	/**
	 * @return the contactList
	 */
	public ListView getContactList() {
		return contactList;
	}

	/**
	 * @return the display
	 */
	public ContactView getDisplay() {
		return display;
	}

	/**
	 * @return the sortMenu
	 */
	public Menu getSortMenu() {
		return sortMenu;
	}
}
